home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1997
/
MacHack 1997.toast
/
Other Stuff
/
Other Stuff ’97
/
PowerOS Development
/
basic kernel source
/
exception_stub.s
< prev
next >
Wrap
Text File
|
1997-06-26
|
2KB
|
108 lines
/*
exceptions.s
exception handler entries for PowerOS
copyright 1996-1997 by Ben Martz
all rights reserved world wide
ANY AND ALL MODIFICATIONS TO THIS SOURCE MUST CREDIT THE ORIGINAL
AUTHOR, BEN MARTZ (benmartz@ic.net), AND MUST BE GIVEN TO THE AUTHOR
FOR INTEGRATION INTO THE MAIN PowerOS SOURCE TREE. THANK YOU FOR YOUR
COOPERATION!
*/
#define _exception(addr, entry) exception(addr, _UnknownException)
/******************************************************************************/
#define exception(addr, entry) \
. = addr; \
b entry;
/******************************************************************************/
#define ENTER_EXCEPTION \
/* save r30 and r31 so that we can use them */ \
mtsprg 0,r31; \
mtsprg 1,r30; \
/* put the exception_frame into r31 */ \
lis r31,exception_frame@ha; \
ori r31,r31,exception_frame@l; \
/* save XER, CTR, CR, LR */ \
mfxer r30; \
stw r30,0(r31); \
mfctr r30; \
stw r30,4(r31); \
mfcr r30; \
stw r30,8(r31); \
mflr r30; \
stw r30,12(r31); \
/* save r0 - r12 */ \
stw r0,16(r31); \
stw r1,20(r31); \
stw r2,24(r31); \
stw r3,28(r31); \
stw r4,32(r31); \
stw r5,36(r31); \
stw r6,40(r31); \
stw r7,44(r31); \
stw r8,48(r31); \
stw r9,52(r31); \
stw r10,56(r31); \
stw r11,60(r31); \
stw r12,64(r31); \
/* move to the kernel stack */ \
lis r31,kernel_stack@ha; \
ori r31,r31,kernel_stack@l; \
mr r1,r31; \
/* save the exception MSR */ \
mfmsr r31; \
mtsprg 2,r31; \
/* turn on address translation */ \
lis r31,MSR_KERNEL@h; \
ori r31,r31,MSR_KERNEL@l; \
mtmsr r31; \
sync;
/******************************************************************************/
#define EXIT_EXCEPTION \
/* restore the exception MSR */ \
mfsprg r31,2; \
mtmsr r31; \
sync; \
/* put the exception_frame into r31 */ \
lis r31,exception_frame@ha; \
ori r31,r31,exception_frame@l; \
/* restore XER, CTR, CR, LR */ \
lwz r30,0(r31); \
mtxer r30; \
lwz r30,4(r31); \
mtctr r30; \
lwz r30,8(r31); \
mtcr r30; \
lwz r30,12(r31); \
mtlr r30; \
/* restore r0 - r12 */ \
lwz r0,16(r31); \
lwz r1,20(r31); \
lwz r2,24(r31); \
lwz r3,28(r31); \
lwz r4,32(r31); \
lwz r5,36(r31); \
lwz r6,40(r31); \
lwz r7,44(r31); \
lwz r8,48(r31); \
lwz r9,52(r31); \
lwz r10,56(r31); \
lwz r11,60(r31); \
lwz r12,64(r31); \
/* set up the new MSR for rfi */ \
lis r30,MSR_KERNEL@h; \
ori r30,r30,MSR_KERNEL@l; \
mtsrr1 r30; \
/* restore r30 and r31 */ \
mfsprg r31,0; \
mfsprg r30,1; \
/* return */ \
rfi;